﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace RegularExpressionExercises
{
    class RealNumber
    {
        static bool ValidateRealNumber(Regex regx, string number)
        {
            bool valid = regx.IsMatch(number);
            return valid;
        }

        static void Main()
        {
            string pattern = @"\A((\-?[1-9]+(\.[\d]+)?|([1-9][0-9]*)|0)|(0\.\d+))\Z";
            Regex regx = new Regex(pattern);

            string[] numbers = {"0", "33", ".35", "2-3", "-2381.78132", "4.3347", "12.00", "0.34", "+3", 
                                   "--2", "-0", "-2", "24 543", "01.23", "12.", "11,23", "12е7" };
            foreach (string number in numbers)
            {
                string str = (ValidateRealNumber(regx, number))? " " : " NOT ";
                Console.WriteLine("{0,11} is{1}a valid real number", number, str);
            }
        }
    }
}
